#include "stdafx.h"
#include <locale.h>
#include <time.h>

#ifndef BUILD_VC6

extern "C"
int my_fprintf(FILE* const _Stream, char const* const _Format, ...)
{
	int _Result;
	va_list _ArgList;
	va_start(_ArgList, _Format);
	_Result = vfprintf(_Stream, _Format, _ArgList);
	va_end(_ArgList);
	return _Result;
}

extern "C"
int my_sprintf(char* const _Buffer, char const* const _Format, ...)
{
	int _Result;
	va_list _ArgList;
	va_start(_ArgList, _Format);

#pragma warning(push)
#pragma warning(disable: 4996) // Deprecation
	_Result = vsprintf(_Buffer, _Format, _ArgList);
#pragma warning(pop)

	va_end(_ArgList);
	return _Result;
}

extern "C"
int my_printf(char const* const _Format, ...)
{
	int _Result;
	va_list _ArgList;
	va_start(_ArgList, _Format);
	_Result = vfprintf(stdout, _Format, _ArgList);
	va_end(_ArgList);
	return _Result;
}

extern "C"
int my_fscanf(FILE* const _Stream, char const* const _Format, ...)
{
	int _Result;
	va_list _ArgList;
	va_start(_ArgList, _Format);
	_Result = vfscanf(_Stream, _Format, _ArgList);
	va_end(_ArgList);
	return _Result;
}

extern "C"
int my_sscanf(char const* const _Buffer, char const* const _Format, ...)
{
	int _Result;
	va_list _ArgList;
	va_start(_ArgList, _Format);
	_Result = vsscanf(_Buffer, _Format, _ArgList);
	va_end(_ArgList);
	return _Result;
}

extern "C"
int my_filbuf(FILE* file)
{
	return 0;
}

extern "C"
int my_flsbuf(int ch, FILE* file)
{
	return 0;
}

extern "C"
int my_atexit(void(__cdecl* cb)(void))
{
	return atexit(cb);
}

extern "C"
int my_time(int* t)
{
	time_t t1;
	time_t t2;
	t2 = time((time_t*)& t1);
	if (t) {
		*t = (int)t1;
	}
	return (int)t2;
}

#endif // !BUILD_VC6
